<html>
 <head>
    <title>[var.TITLE]</title>
    <link href="[var.ROOT_CSS_DIR]/main.css" rel="STYLESHEET" type="text/css" charset="iso-8859-1" hreflang="en-us">
    <link href="[var.ROOT_CSS_DIR]/facet/style.css" rel="STYLESHEET" type="text/css" charset="iso-8859-1" hreflang="en-us">
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmasks.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jquery.min.js"></script>
 </head>
 <body bgcolor="FFFFFF" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
    <table border="0" cellspacing="0" cellpadding="0" width="100%" align="[var.POSITION]">
        <tr height="100%">
            <td>
            <table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
                <tr valign="top">
                    <td width="100%">
                        <table border="0" cellspacing="0" cellpadding="5" width="100%">
                            <tr>
                                <td class="FacetHeaderContent" align="left">.:Services Lookup:. </td>
                            </tr>
                        </table>
                        <table border="0" cellspacing="0" cellpadding="5" width="100%">
                            <tr>
                                <td class="content2">
                                    <table border="0" cellspacing="0" cellpadding="0">
                                    <form  method="post" action="[var.FileName]?FormName=[var.FormName]&[var.PreserveGet]">
                                        <tr>
                                            <td class="fieldCaption">Services Code</td>
                                            <td class="fieldCaption">:</td>
                                            <td>
                                            <input type="text" name="codeSearch" size="10" maxlength="50" class="input" value="[var.FCode]">
                                                                                                                                                                                                    <input type="hidden" name="SendToBack" value="1">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="fieldCaption">Services Name</td>
                                            <td class="fieldCaption">:</td>
                                            <td>
                                            <input type="text" name="nameSearch" size="35" maxlength="50" class="input" value="[var.FNama]">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="menuHeader"></td>
                                            <td class="menuHeader"></td>
                                            <td align="right">
                                            <input type="submit" name="Action" value="Search" class="button" >
                                            </td>
                                        </tr>
                                    </form>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <td >&nbsp;</td>
                            </tr>
                        </table>
                        <table border="0" cellspacing="0" cellpadding="0" width="100%">
                            <tr>
                              <td>
                         <!-- GRID SECTION -->
                                    <table border="0" width="100%" cellpadding="3" cellspacing="1" class="FacetFormTABLE" align="left">
                                    <form method=post name="[var.HTMLGridList]" >
                                      <tr>
                                        <td nowrap class="FacetColumnTD" align="center">No.</td>
                                        <td nowrap class="FacetColumnTD" align="center">Code</td>
                                        <td nowrap class="FacetColumnTD" align="center">Name</td>
                                      </tr>

                                      <tr>
                                        <td nowrap class="FacetDataTD">[blg.#]</td>
                                        <td class="FacetDataTD">
                                           <!--<a href="javascript:GetCustomer('[blg.services_id]','[blg.services_code]','[blg.services_name]','[blg.act_id]');">[blg.services_code]</a>-->
                                           <a href="javascript:if(checkData('[blg.services_id]') == 1) {GetCustomer('[blg.services_id]','[blg.services_code]','[blg.services_name]','[blg.act_id]','[blg.amount]','[blg.skada]');}">[blg.services_code]</a>
                                        </td>
                                        <td class="FacetDataTD">[blg.services_name;block=tr;]</td>
                                      </tr>

                                      <tr>
                                        <td colspan="8" class="FacetDataTD">[blg;block=tr;nodata]No records</td>
                                      </tr>
                                      
                                      <tr>
                                        <td colspan="8" nowrap class="FacetColumnTD">[tbs_check.1;block=tr;if [var.RecCnt]!=0]
                                            <table border="0" align="left" cellpadding="0" cellspacing="0">
                                              <tr align="center">[tbs_check.1;block=table;if [var.RecCnt]!=0]
                                                <td width="16" class="FacetColumnTD"><a href="[sys.script_name]?PageNum=[nv.first;endpoint;friend2=a]&[var.PreserveGet]&codeSearch=[var.FCode]&nameSearch=[var.FNama]">|&lt;</a></td>
                                                <td width="16" class="FacetColumnTD"><a href="[sys.script_name]?PageNum=[nv.prev;endpoint;friend2=a]&[var.PreserveGet]&codeSearch=[var.FCode]&nameSearch=[var.FNama]">&lt;</a></td>
                                                <td width="16" class="FacetColumnTD"><a href="[sys.script_name]?PageNum=[nv.page;block=td]&[var.PreserveGet]&codeSearch=[var.FCode]&nameSearch=[var.FNama]">[nv.page]</a></td>
                                                <td width="16" bgcolor="#B7B3B7"><strong>[nv.page;block=td;currpage]</strong></td>
                                                <td width="16" class="FacetColumnTD"><a href="[sys.script_name]?PageNum=[nv.next;endpoint;friend2=a]&[var.PreserveGet]&codeSearch=[var.FCode]&nameSearch=[var.FNama]">&gt;</a></td>
                                                <td width="16" class="FacetColumnTD"><a href="[sys.script_name]?PageNum=[nv.last;endpoint;friend2=a]&[var.PreserveGet]&codeSearch=[var.FCode]&nameSearch=[var.FNama]">&gt;|</a></td>
                                              </tr>
                                            </table>
                                        </td>
                                      </tr>
                                      </form>
                                    </table>
                        <!-- GRID SECTION -->
                               </td>
                            </tr>
                            <tr>
                              <td>

                              &nbsp;
                              </td>
                            </tr>
                            </table>
                    </td>
                </tr>
            </table>

            </td>
        </tr>
    </table>
 </body>
<script>
 var Address;
 var NPWP;

 function SetOther(addr,npwp) {
    Address = addr;
    NPWP = npwp;
 }

 function GetCustomer(services_id,services_code,services_name,act_id,amount,skada) {

 oMask = new Mask('#,###.#0', 'number');
 var curr = "[var.curr]";
  
 var BufferOpener;
 var no_urut = [var.no_urut];
 var total = 0;
 var PageSize = [var.PageSize];
 var dk999 = "";

     for(i=1;i<=PageSize;i++){
        eval("var Jumlah = window.opener.document.[var.FormName].jumlah"+i+".value");

        if(Jumlah == "") {
            Jumlah = 0;
        }

        Jumlah = String(Jumlah);
        Jumlah = (Jumlah.replace(/,/g, "")) * 1;

        //alert("TotalAmount: " + TotalAmount);
        total = total + Jumlah;
        //alert("total: " + total);
    }

    amount = String(amount);
    amount = (amount.replace(/,/g, "")) * 1;
    
    //If Curr is USD
    //if(curr == "USD")
    //{amount = amount * [var.kursUSD];};
    //End IF
    
    total = total + amount
    
    
    //Output Grand Total
    
    if(total < 0)
    {
		total = total * -1;
		dk999 = "K";
	}
	
	else
	{
		dk999 = "D";
	}
    
    var maskJumlah = oMask.format(total);
    window.opener.document.[var.FormName].total_trans.value = maskJumlah;
    
    //Einde Output Grand Total
    
    
     BufferOpener = window.opener.document.body.innerHTML;

     var maskJumlahDlmGrid = oMask.format(amount);

     if(no_urut != "")
     {
         window.opener.document.[var.FormName].services_id[var.no_urut].value = services_id;
         window.opener.document.[var.FormName].services_code[var.no_urut].value = services_code;
         window.opener.document.[var.FormName].services_name[var.no_urut].value = services_name;
         window.opener.document.[var.FormName].uraian[var.no_urut].value = services_name;
         window.opener.document.[var.FormName].act_id[var.no_urut].value = act_id;
         window.opener.document.[var.FormName].jumlah[var.no_urut].value = maskJumlahDlmGrid;
         window.opener.document.[var.FormName].skada[var.no_urut].value = skada;
         window.opener.document.[var.FormName].dk999.value = dk999;
     }

     else
     {
         window.opener.document.[var.FormName].services_id.value = services_id;
         window.opener.document.[var.FormName].services_code.value = services_code;
         window.opener.document.[var.FormName].services_name.value = services_name;
         window.opener.document.[var.FormName].uraian[var.no_urut].value = services_name;
         window.opener.document.[var.FormName].act_id[var.no_urut].value = act_id;
         window.opener.document.[var.FormName].jumlah[var.no_urut].value = amount;
         window.opener.document.[var.FormName].skada[var.no_urut].value = skada;
         window.opener.document.[var.FormName].dk999.value = dk999;
     }

     self.close();
 }
 
 
 
 function AddNew() {
    self.location.replace('ais_transaction_debtur.php?PageMode=Form');
 }



 function checkData(services_id){
    var result = 1;

    for(i=1;i<=[var.PageSize];i++){
        if( services_id == eval("window.opener.document.[var.FormName].services_id"+i+".value")){
            alert("Data yang anda pilih sudah termasuk di dalam list Nota Debet");
            result = 0;
            break;
        }


    }


    return result;

 }


</script>
</html>
